<?php
/* ----------------------------------------------------------
--               JacoCMS by Jaco Ruit                      --
-------------------------------------------------------------
--     JacoCMS is Open Source and is lincenced under       --
--             GNU General Public Licence v3               --
--          http://www.gnu.org/copyleft/gpl.html           --
-------------------------------------------------------------
--       Please don't remove any text from the footers.    --
-------------------------------------------------------------
-- Credits:   * Jaco Ruit          ~     Scripts,MySQL     --     
-----------------------------------------------------------*/

#important includes
include '../includes/config.php';
include '../includes/database.ext.class.php'; 

#create database connection
$database = new Database();
$database->connect('../includes/config.php');

#finish includes
include '../includes/core.ext.class.php';
include '../includes/settings.class.php';
include '../includes/user.class.php';

#vars, classes
$settings = new Settings();
$core = new Core();
$user = new User();
$panelcode = "<p>Loading..</p>";


session_start();
if((isset($_SESSION['jcmsuname'])) && (isset($_SESSION['jcmspwd'])))
{
	$uname = $core->filter($_SESSION['jcmsuname']);
	$pwd = $core->filter($_SESSION['jcmspwd']);
	
	#validate cookies' info
	if ($user->validateCookie($uname, $pwd) == true)
	{
		
		if(!$user->isAdmin($uname))
		{
			$panelcode = '<div id="panelinfo"><p>You do not have permission to view this.</p></div>';
			$title = 'Access Denied';
		}
		else
		{
			$vGallery = $settings->videoGalleryEnabled();
			if ($vGallery == true)
			{
				$panelcode = '<div id="form"><form name="editsettings" method="post" action="function.editsettings"><p>Website Name</p><input type="text" name="websitename" size="40" value="' . $settings->getWebsiteName() . '" /><br /><p>Website URL</p><input type="text" name="websiteurl" size="40" value="' . $settings->getWebsiteURL()  . '" /><p style="font-size:10px;">NO http:// prefix! NO / at the end!</p><br /><p>Style Folder Name</p><input type="text" name="style" size="40" value="' . $settings->loadStyle() . '" /><br /><p>Video Gallery</p><br /><input type="radio" name="videogallery" value="1" checked="yes"><p style="font-size:8px;">Enabled</p><br /><input type="radio" name="videogallery" value="0"><p style="font-size:8px;">Disabled</p><br /><input type="submit" name="submit" value="Save" /></div>';
			}
			else if ($vGallery == false)
			{
				$panelcode = '<div id="form"><form name="editsettings" method="post" action="function.editsettings"><p>Website Name</p><input type="text" name="websitename" size="40" value="' . $settings->getWebsiteName() . '" /><br /><p>Website URL</p><input type="text" name="websiteurl" size="40" value="' . $settings->getWebsiteURL()  . '" /><p style="font-size:10px;">NO http:// prefix! NO / at the end!</p><br /><p>Style Folder Name</p><input type="text" name="style" size="40" value="' . $settings->loadStyle() . '" /><br /><p>Video Gallery</p><br /><input type="radio" name="videogallery" value="1" ><p style="font-size:8px;">Enabled</p><br /><input type="radio" name="videogallery" value="0" checked="yes"><p style="font-size:8px;">Disabled</p><br /><input type="submit" name="submit" value="Save" /></div>';		
			}
			$title = "Settings";
		}
		
		#create template
		$smarty->assign("page", "Settings");
		$smarty->assign("webname", $settings->getWebsiteName());
		$smarty->assign("panelcode", $panelcode);
		$smarty->display("panel.tpl");
	}
	else
	{
		#evil cookies!
		
		
		
		session_destroy();
		header("Location: login");
	}
}
else
{
	header("Location: login");
}

?>